unit U_fm_rel_sol;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.Buttons,
  Vcl.Grids, Vcl.DBGrids, frxClass, frxDBSet, Vcl.ImgList, Vcl.ToolWin,
  Vcl.ExtCtrls;

type
  Tfm_rel_sol = class(TForm)
    dbgrd1: TDBGrid;
    lbl9: TLabel;
    dataset_sol: TfrxDBDataset;
    grp1: TGroupBox;
    lbl12: TLabel;
    lbl13: TLabel;
    edt_id: TEdit;
    edt_por: TEdit;
    frxReport1: TfrxReport;
    lbl11: TLabel;
    grp2: TGroupBox;
    lbl15: TLabel;
    lbl16: TLabel;
    lbl17: TLabel;
    lbl18: TLabel;
    dtp_inicio: TDateTimePicker;
    dtp_fim: TDateTimePicker;
    lbl23: TLabel;
    edt_caso: TEdit;
    grp3: TGroupBox;
    lbl20: TLabel;
    edt_status: TEdit;
    edt_programador: TEdit;
    lbl10: TLabel;
    il1: TImageList;
    btn1: TSpeedButton;
    btn2: TSpeedButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn4Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fm_rel_sol: Tfm_rel_sol;

implementation

{$R *.dfm}

uses U_fm_solicitacao, U_dm_principal;

procedure Tfm_rel_sol.btn1Click(Sender: TObject);
begin
       dm_principal.cds_sol.Close;
       dm_principal.sq_sol.SQL.Text:='select s.id_projeto ,'
                                            +#13+'s.data,'
                                            +#13+'s.id,'
                                            +#13+'s.solicidado,'
                                            +#13+' s.status,'
                                            +#13+' s.resolvido,'
                                            +#13+' s.testado_por,'
                                            +#13+' s.selecte,'
                                            +#13+' s.id_caso_teste, '
                                            +#13+' s.prioridade, '
                                            +#13+' s.versao, '
                                            +#13+' s.tipo_solicitacao, '
                                            +#13+'s.datanow,'
                                            +#13+'s.programador,'
                                            +#13+'s.historico'
                                            +#13+'from solicitacao s  Where s.id <> 0 ' ;
                                         //  +#13+' inner join projetos p on ( s.id_projeto = p.codigo )'


             if  length(trim(edt_por.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND s.id_projeto containing '+QuotedStr(edt_por.Text));

             if Length(Trim(edt_id.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND s.id containing '+QuotedStr(edt_id.Text));

              if Length(Trim(edt_programador.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND s.programador containing '+QuotedStr(edt_programador.Text));

              if dtp_inicio.Checked then
                dm_principal.sq_sol.SQL.Add('AND s.data BETWEEN '+QuotedStr((FormatDateTime('MM/DD/YYYY',dtp_inicio.Date)))+' AND '+QuotedStr((FormatDateTime('MM/DD/YYYY',dtp_fim.Date))));

               if Length(Trim(edt_status.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND  s.status containing '+QuotedStr(edt_status.Text));


             if Length(Trim(edt_caso.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND  s.id_caso_teste containing '+QuotedStr(edt_caso.Text));

             dm_principal.cds_sol.open;
end;

procedure Tfm_rel_sol.btn2Click(Sender: TObject);
begin
dm_principal.cds_sol.Open;
frxReport1.ShowReport(True);
end;

procedure Tfm_rel_sol.btn3Click(Sender: TObject);
begin
 dm_principal.cds_sol.Close;
       dm_principal.sq_sol.SQL.Text:='select s.id_projeto ,'
                                            +#13+'s.data,'
                                            +#13+'s.id,'
                                            +#13+'s.solicidado,'
                                            +#13+' s.status,'
                                            +#13+' s.resolvido,'
                                            +#13+' s.testado_por,'
                                            +#13+' s.selecte,'
                                            +#13+' s.id_caso_teste, '
                                            +#13+' s.prioridade, '
                                            +#13+' s.versao, '
                                            +#13+' s.tipo_solicitacao, '
                                            +#13+'s.datanow,'
                                            +#13+'s.programador,'
                                            +#13+'s.historico'
                                            +#13+'from solicitacao s  Where s.id <> 0 ' ;
                                         //  +#13+' inner join projetos p on ( s.id_projeto = p.codigo )'


             if  length(trim(edt_por.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND s.id_projeto containing '+QuotedStr(edt_por.Text));

             if Length(Trim(edt_id.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND s.id containing '+QuotedStr(edt_id.Text));

              if Length(Trim(edt_programador.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND s.programador containing '+QuotedStr(edt_programador.Text));

              if dtp_inicio.Checked then
                dm_principal.sq_sol.SQL.Add('AND s.data BETWEEN '+QuotedStr((FormatDateTime('MM/DD/YYYY',dtp_inicio.Date)))+' AND '+QuotedStr((FormatDateTime('MM/DD/YYYY',dtp_fim.Date))));

               if Length(Trim(edt_status.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND  s.status containing '+QuotedStr(edt_status.Text));


             if Length(Trim(edt_caso.Text))>0 then
             dm_principal.sq_sol.SQL.Add(' AND  s.id_caso_teste containing '+QuotedStr(edt_caso.Text));

             dm_principal.cds_sol.open;
end;

procedure Tfm_rel_sol.btn4Click(Sender: TObject);
begin
dm_principal.cds_sol.Open;
frxReport1.ShowReport(True);
end;

end.
